﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BLL.ComplexClasses;
namespace ithub.Controllers
{
    public class EmailInfoController : Controller
    {
        //
        // GET: /EmailInfo/

        public ActionResult Index(long id, string module)
        {
            return PartialView("Index", GetEmailInfo(id, module));
        }

        public ActionResult SaveRecord(AdditionalInfo objAdditionalInfo)
        {
            BLL.BL_AdditionalInfo.SaveRecord(objAdditionalInfo);
            return PartialView("Index", GetEmailInfo(objAdditionalInfo.id, objAdditionalInfo.module));
        }

        private List<AdditionalInfo> GetEmailInfo(long id, string module)
        {
            List<AdditionalInfo> lstAddtionalInfo = BLL.BL_AdditionalInfo.GetAdditionalInfos(id, module);

            List<AdditionalInfo> lstEmail = new List<AdditionalInfo>();

            if (lstAddtionalInfo.Count > 0)
            {
                lstEmail = lstAddtionalInfo.Where(m => m.type == (int)App_Utils.clsConstants.Info_Type.Email).ToList();
            }
            return lstEmail;
        }

    }
}
